package com.example.oraceldemo.mapper;

import com.example.oraceldemo.entity.TabStar;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.oraceldemo.entity.tb;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author 张子行
 * @since 2022-10-09
 */
public interface TabStarMapper extends BaseMapper<TabStar> {
    @Select("select a.user_name user,a.zw_userid userid,sum(a.show_steps) bs,b.phase_total_steps bqbs from tab_run a\n" +
            "left join tab_user_info b on a.zw_userid=b.userid\n" +
            "where a.date>='2024-08-01' and a.date<='2024-08-31' group by a.user_name")
    List<tb> a();

    @Select("select DISTINCT a.id,a.dept_id as did,a.dept_name,a.`name`,b.goal_time from (select * from tab_oracle_user where maintain_time = '2024-11-29') a left join (select * from tab_star " +
            "where goal_day like '%2024-12%')b on a.id=b.userid\n" +
            "where b.userid is not null ORDER BY a.`name`")
    ArrayList<newbb> bb();

    @Select("select count(*) from tab_star where goal_time > '2024-01-03' and goal_time <= #{time} and userid = #{id}")
    int cc(@Param("time") String time, @Param("id") int id);
}
